/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ImportDataFromPhone;

import java.util.ArrayList;
import java.util.List;


/**
 *
 * @author ash
 */
public class Container<T extends Record> {
    private List<T> records;
    private String header;
    
    public String getHeader(){
        return header;
    }
    
    public T get(int index){
        return records.get(index);
    }
    
    public void add(T newRecord){
        records.add(newRecord);
    }
    
    public int size(){
        return records.size();
    }
    
    Container(Class<T> cls){
        records = new ArrayList<>();
        header = getRecordHeader(cls);
    }
    
    private String getRecordHeader(Class<T> cls){
        String head = null;
        try {
            head = cls.newInstance().getHeader();
        } catch (Exception e){
            System.out.println(e.getMessage());
        }
        return head;
    }
            
    public static void main(String[] a){
        Container<ProcessedRecord> x = new Container<>(ProcessedRecord.class);
        x.add(new ProcessedRecord("1", "2", "3"));
        System.out.println(x.getHeader());
        System.out.println(x.get(0).getCSVString());
        
        Container<CategorizedRecord> y = new Container<>(CategorizedRecord.class);
        System.out.println(y.getHeader());
    }
            
}
